package com.mxprojects.gui
{
	import com.mxprojects.constructors.Divider;
	import com.mxprojects.constructors.DrawBorder;
	import com.mxprojects.io.Config;
	import com.mxprojects.language.Language;
	import com.mxprojects.language.Word;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class ThreadHeader extends BaseForumElement
	{
		private const DIVIDER_COUNT:int = 4;
		
		public var topic:TextField;
		public var topicStarter:TextField;
		public var replies:TextField;
		public var views:TextField;
		public var lastPost:TextField;
				
		public function ThreadHeader(){
			//set the values from CSS
			topic.styleSheet = Styles.css;
			topicStarter.styleSheet = Styles.css;
			replies.styleSheet = Styles.css;
			views.styleSheet = Styles.css;
			lastPost.styleSheet = Styles.css;
			
			//when this is put on the stage load the language
			topic.htmlText = "<span class=\"threadHeaderTopic\">" + Language.main(Word.TOPIC) + "</span>";
			topicStarter.htmlText = "<span class=\"threadHeaderTopicStarter\">" + Language.main(Word.TOPIC_STARTER) + "</span>";
			replies.htmlText = "<span class=\"threadHeaderReplies\">" + Language.main(Word.REPLIES) + "</span>";
			views.htmlText = "<span class=\"threadHeaderViews\">" + Language.main(Word.VIEWS) + "</span>";
			lastPost.htmlText = "<span class=\"threadHeaderLastPost\">" + Language.main(Word.LAST_POST) +" / "+ Language.main(Word.USERNAME) + "</span>";
			
			//parse the CSS
			super.init(".threadHeaderBackground", DIVIDER_COUNT);
			
			//place the stuff where it needs to be
			//placeStuff();
		}
		
		override public function resize():void {
			placeStuff();
			super.resize();
		}
		
		private function placeStuff():void {
			//place titles in proper spot
			lastPost.x = Math.round(MXP3.wStage - lastPost.width - (Config.TEXT_PADDING/2));
			views.x = Math.round(lastPost.x - views.width - Config.TEXT_PADDING);
			replies.x = Math.round(views.x - replies.width - Config.TEXT_PADDING);
			topicStarter.x = Math.round(replies.x - topicStarter.width - Config.TEXT_PADDING);
			
			//move the dividers
			getDivider(0).x = Math.round(topicStarter.x - (Config.TEXT_PADDING/2));
			getDivider(1).x = Math.round(replies.x - (Config.TEXT_PADDING/2));
			getDivider(2).x = Math.round(views.x - (Config.TEXT_PADDING/2));
			getDivider(3).x = Math.round(lastPost.x - (Config.TEXT_PADDING/2));
		}
		
	}
}